using System;
using System.Collections.Generic;

namespace SY.WebSite.Entity
{
	/// <summary>
	///	
	/// </summary>
	[Serializable]
	public class AuctionItem : IEntity
	{
		public const string RESERVE_CONST = "AuctionItem";
			
		#region Private Members
		private int _id; 
		private int _auctionId; 
		private string _title; 
		private string _description; 
		private double _price; 
		private string _image; 
		private int _bidder; 
		private string _bidderName; 
		private int _bidAmount; 
		private int _status; 		
		[NonSerialized]
        private string _reserve;
		#endregion
		
		#region Default ( Empty ) Class Constuctor
		/// <summary>
		/// default constructor
		/// </summary>
		public AuctionItem()
		{
			_id = 0; 
			_auctionId = 0; 
			_title = null; 
			_description = null; 
			_price = new double(); 
			_image = null; 
			_bidder = 0; 
			_bidderName = null; 
			_bidAmount = 0; 
			_status = 0; 
		}
		#endregion // End of Default ( Empty ) Class Constuctor
		
		public Dictionary<string, object> ToDictionary()
		{
			Dictionary<string, object> dictionary = new Dictionary<string, object>();
		
			dictionary.Add("Id",_id);
			dictionary.Add("AuctionId",_auctionId);
			dictionary.Add("Title",_title);
			dictionary.Add("Description",_description);
			dictionary.Add("Price",_price);
			dictionary.Add("Image",_image);
			dictionary.Add("Bidder",_bidder);
			dictionary.Add("BidderName",_bidderName);
			dictionary.Add("BidAmount",_bidAmount);
			dictionary.Add("Status",_status);
			
			dictionary.Add("Reserve",Reserve);//特殊
			return dictionary;
		}
		
		#region Public Properties
		/// <summary>
		/// 
		/// </summary>		
		public int Id
		{
			get { return _id; }
			set { _id = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int AuctionId
		{
			get { return _auctionId; }
			set { _auctionId = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string Title
		{
			get { return _title; }
			set	
			{
				if( value!= null && value.Length > 200)
					throw new ArgumentOutOfRangeException(@"Invalid value for Title", value, value);
				
				_title = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string Description
		{
			get { return _description; }
			set	
			{
				if( value!= null && value.Length > 500)
					throw new ArgumentOutOfRangeException(@"Invalid value for Description", value, value);
				
				_description = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public double Price
		{
			get { return _price; }
			set { _price = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string Image
		{
			get { return _image; }
			set	
			{
				if( value!= null && value.Length > 200)
					throw new ArgumentOutOfRangeException(@"Invalid value for Image", value, value);
				
				_image = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int Bidder
		{
			get { return _bidder; }
			set { _bidder = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public string BidderName
		{
			get { return _bidderName; }
			set	
			{
				if( value!= null && value.Length > 16)
					throw new ArgumentOutOfRangeException(@"Invalid value for BidderName", value, value);
				
				_bidderName = value;
			}
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int BidAmount
		{
			get { return _bidAmount; }
			set { _bidAmount = value; }
		}
			
		/// <summary>
		/// 
		/// </summary>		
		public int Status
		{
			get { return _status; }
			set { _status = value; }
		}
			
		/// <summary>
        /// 保留属性
        /// </summary>
        public string Reserve
        {
            get 
            {
                if (string.IsNullOrEmpty(_reserve))
                    return RESERVE_CONST  ;

                return _reserve; 
            }
            set { _reserve = value; }
        }
		#endregion 
	}
}
